/* -*- mode: c++ -*-
** button.cpp
** 
** Made by Kjetil Svarstad
** 
*/

#include "button.h"

// Functionality for the Button class

// Constructor
Button::Button (sc_module_name buttonName, int buttonNumber) : sc_module (buttonName)
{
  number = buttonNumber;
  light = false; // Light is off when button is created.
  SC_HAS_PROCESS (Button);
  SC_THREAD(main);
}

void Button::switchLight(bool b)
{
	light = b;
	printf("Button%i : Light is %s\n",number, (light ? "on" : "off"));
}

void Button::main()
{
	while(true)
	{
		wait(PUSH.posedge_event());
		busp->buttonPushed(number);
	}
}
